<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title>季报</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_739294_oqd9y2wamo.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/my.css" media="all">
</head>

<body>
    <div class="layui-form" style="margin-left:20px;margin-top:15px;margin-bottom:-20px">
        <div class="layui-form-item">
            <label class="layui-form-label">报表年份</label>
            <div class="layui-inline">
                <input type="text" class="layui-input" id="datetime" autocomplete="off" placeholder="请选择年份">
            </div>
            季度：
            <div class="layui-inline">
                <select name="quarter" id="quarter">
                    <option value=""></option>
                    <option value="1" id="s1">第一季度</option>
                    <option value="2" id="s2">第二季度</option>
                    <option value="3" id="s3">第三季度</option>
                    <option value="4" id="s4">第四季度</option>
              </select>
            </div>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;医院名称：
            <div class="layui-inline" style="width:300px">
                <select name="hid" id="select" style="width:300px" class="layui-input" lay-search>
                    <option value=""></option>
                </select>
            </div>
            <div class="layui-btn-group">
                <button class="layui-btn layui-btn-normal" data-type="reload" id="search"><i class="layui-icon">&#xe615;</i>查询</button>
            </div>
        </div>
    </div>
    <table id="demo" lay-filter="test"></table>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script src="../../layuiadmin/layui/jquery-3.3.1.min.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index'], function() {


            layui.use('laydate', function() {
                var laydate = layui.laydate;

                //执行一个laydate实例
                laydate.render({
                    elem: '#datetime' //指定元素
                        ,
                    type: 'year',
                    max: 0,
                    theme: "#1e9fff",
                    done: function(v, d, ed) {
                        var date = new Date();
                        var y = date.getFullYear(); //今年
                        var m = date.getMonth() + 1; //本月
                        /* 根据所选的年份 决定select的option是否禁用*/
                        if (d.year == y) {
                            if (1 <= m && m <= 3) {
                                $("#s2").attr("disabled", true);
                                $("#s3").attr("disabled", true);
                                $("#s4").attr("disabled", true);

                            } else if (4 <= m && m <= 6) {
                                $("#s2").attr("disabled", false);
                                $("#s3").attr("disabled", true);
                                $("#s4").attr("disabled", true);
                            } else if (7 <= m && m <= 9) {
                                $("#s2").attr("disabled", false);
                                $("#s3").attr("disabled", false);
                                $("#s4").attr("disabled", true);
                            } else if (10 <= m && m <= 12) {
                                $("#s2").attr("disabled", false);
                                $("#s3").attr("disabled", false);
                                $("#s4").attr("disabled", false);
                            }
                        } else {
                            $("#s2").attr("disabled", false);
                            $("#s3").attr("disabled", false);
                            $("#s4").attr("disabled", false);
                        }
                        layui.form.render();
                    }
                });
            });
            $.ajax({
                url: "../../../Cust/hospital",
                dataType: 'json',
                type: "get",
                success: function(res) {
                    $.each(res.data, function(index) {
                        var id = res.data[index].hid;
                        var name = res.data[index].name;
                        $("#select").append("<option value='" + id + "'>" + name + "</option>")
                    });
                    layui.form.render();
                }

            })
            layui.use('table', function() {
                var table = layui.table;
                var $ = layui.$;

                var tableIns = table.render({
                    elem: '#demo',
                    height: 'full-90',
                    data: [],
                    totalRow: true,
                    cols: [
                        [ //表头
                            {
                                field: 'hospname',
                                title: '医院名称',
                                align: 'center',
                                width: '12%',
                                totalRowText: "合计",
                            }, {
                                field: 'totalweight',
                                title: '总重量(Kg)',
                                width: '8.5%',
                                align: 'center',
                                totalRow: true,
                            }, {
                                field: 'weight_0',
                                title: '感染性废物(Kg)',
                                width: '8.5%',
                                align: 'center',
                                totalRow: true,
                            }, {
                                field: 'weight_1',
                                title: '损伤性废物(Kg)',
                                width: '8.5%',
                                align: 'center',
                                totalRow: true,
                            }, {
                                field: 'weight_5',
                                title: '病理性废物(Kg)',
                                width: '8.5%',
                                align: 'center',
                                totalRow: true,
                            }, {
                                field: 'weight_4',
                                title: '药物性废物(Kg)',
                                width: '8.5%',
                                align: 'center',
                                totalRow: true,
                            }, {
                                field: 'weight_3',
                                title: '化学性废物(Kg)',
                                width: '8.5%',
                                align: 'center',
                                totalRow: true,
                            }, {
                                field: 'weight_6',
                                title: '输液瓶(Kg)',
                                width: '8.5%',
                                align: 'center',
                                totalRow: true,
                            }, {
                                field: 'weight_7',
                                title: '输液袋(Kg)',
                                width: '8.5%',
                                align: 'center',
                                totalRow: true,
                            }, {
                                field: 'nval_2',
                                title: '利器盒(只)',
                                width: '8.5%',
                                align: 'center',
                                totalRow: true,
                            }, {
                                field: 'nval_5',
                                title: '胎盘(只)',
                                width: '8.5%',
                                align: 'center',
                                totalRow: true,
                            }
                        ]
                    ],
                    skin: 'row', //表格风格				
                    even: true,
                });
                $("#search").on("click", function() {
                    tableIns.reload({
                        url: '../../../Report/reportQuater',
                        where: {
                            date: $("#datetime").val(),
                            quarter: $("#quarter option:selected").val(),
                            hid: $("#select option:selected").val()
                        }
                    })
                })
            });
        });
    </script>
</body>

</html>